home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / dvtools / demos / dwpdemo / dwp_dsp.c < prev    next >
C/C++ Source or Header  |  1997-05-08  |  7KB  |  266 lines

  1. #ifndef lint
  2. static char SccsId[]= "@(#)dwp_dsp.c    V1.8    3/15/95";
  3. #endif
  4.  
  5. /*------------------------------------------------------------------
  6. | file name -- dwp_disp.c
  7. |
  8. | functions             Description
  9. | ---------             -----------
  10. | InitWindow            Initializes the window
  11. | new_window            Sets up the new window display.
  12. | SetupDynamics         Set up the dynamic display lists.
  13. | draw_screen           Draw the display onto the window.
  14. | close_window          Close the display for one window.
  15. | TermDisplays          Terminates and closes all the windows.
  16. |
  17. |-----------------------------------------------------------------*/
  18.  
  19. #include "std.h"
  20. #include "dvstd.h"
  21. #include "dvGR.h"
  22. #include "Tfundecl.h"
  23. #include "dwp_vars.h"
  24. #include "VTfundecl.h"
  25. #include "VUfundecl.h"
  26. #include "VOfundecl.h"
  27. #include "GRfundecl.h"
  28. #include "dwp_fundecl.h"
  29.  
  30.  
  31.  
  32. #define DEFAULT_SIZE     (RECTANGLE*)NULL
  33. #define DEFAULT_PORTION (RECTANGLE*)NULL
  34.  
  35. #define NEW_LIST        (char)0
  36. #define ADD_TO_LIST        (char)1
  37. #define DELETE_FROM_LIST    (char)2
  38.  
  39. /*-----------------------------------------------------------------
  40. |
  41. |  InitWindow
  42. |       Performs the initialization needed for the display.
  43. |
  44. |       A SCREEN is opened using DVDEVICE and other attributes.
  45. |
  46. */
  47. void 
  48. InitWindow (which)
  49.      int which;
  50. {
  51.   /* Open the window */
  52.   new_window (Device,
  53.               window_size[which].x, window_size[which].y,
  54.               window_name[which],
  55.               window_offset[which].x, window_offset[which].y,
  56.               which);
  57.  
  58.   /* Initialize the window events */
  59.   InitSimpleEvents ();
  60.  
  61.   /* Call RebindData() to rebind to application data */
  62.   RebindData (view[which]);     /* found in dwp_rebind.c */
  63.   SetupDynamics (which);
  64.  
  65.   draw_screen (which);
  66.  
  67.   ActiveScreenIndex = which;
  68.  
  69. }
  70.  
  71.  
  72. /*---------------------------------------------------------------
  73. |   new_window
  74. |       Create a new window with the specified view.
  75. |
  76. */
  77. void 
  78. new_window (device, width, height, name, x, y, window_number)
  79.      char *device;
  80.      int width;
  81.      int height;
  82.      char *name;
  83.      int x;
  84.      int y;
  85.      int window_number;
  86. {
  87.  
  88.   RECTANGLE wvp, dummy;
  89.   int error_code;
  90.   char buf[50];
  91.  
  92.   if (window_status[window_number] == OPEN)
  93.     return;
  94.  
  95.   /* Set the WaitingForExpose flag. This flag will be used
  96.   |  to block updates in our TimeOutProc - HandleDynamics
  97.   */
  98.   WaitingForExpose = YES;
  99.  
  100.  
  101.   if (width == -1 || height == -1)
  102.     DVscreen[window_number] = TscOpenSet (device, NULL,
  103.                                           V_WINDOW_NAME, name,
  104.                                           V_WINDOW_X, x,
  105.                                           V_WINDOW_Y, y,
  106. #ifdef WINNT
  107.                       V_WIN32_ICON_NAME,       "dwpicon",
  108. #ifdef DOUBLE_BUFFER
  109.                       V_WIN32_DOUBLE_BUFFER,  YES,
  110. #endif /* DOUBLE_BUFFER */
  111. #else  /* Not WINNT */
  112.                       V_X_EXPOSURE_BLOCK,    YES,
  113. #endif /* WINNT */
  114.                       V_ACTIVE_CURSOR,
  115.                       V_END_OF_LIST);
  116.     
  117. else
  118.     DVscreen[window_number] = TscOpenSet (device, NULL,
  119.                                           V_WINDOW_WIDTH, width,
  120.                                           V_WINDOW_HEIGHT, height,
  121.                                           V_WINDOW_NAME, name,
  122.                                           V_WINDOW_X, x,
  123.                                           V_WINDOW_Y, y,
  124. #ifdef WINNT
  125.                       V_WIN32_ICON_NAME,        "dwpicon",
  126. #ifdef DOUBLE_BUFFER
  127.                       V_WIN32_DOUBLE_BUFFER,  YES,
  128. #endif /* DOUBLE_BUFFER */
  129. #else  /* Not WINNT */
  130.                       V_X_EXPOSURE_BLOCK,    YES,
  131. #endif /* WINNT */
  132.                       V_ACTIVE_CURSOR,
  133.                       V_END_OF_LIST);
  134. if(!DVscreen[window_number])
  135.  {
  136.    error_code=TscOpenError();
  137. #ifdef WINNT
  138.    sprintf(buf,"Product is not validated. Error code %d.",error_code);
  139.    MessageBox(NULL,buf,"Validation Error",MB_OK);
  140. #else
  141.    fprintf(stderr,"Product is not validated. Error code %d.",error_code);
  142. #endif
  143.    exit(error_code);
  144.   }
  145.  
  146.   view[window_number] = TviLoad (view_name[window_number]);
  147.   drawing[window_number] = TviGetDrawing (view[window_number]);
  148.   VOobBox (drawing[window_number], &wvp, &dummy);
  149.   drawport[window_number] = TdpCreateStretch (DVscreen[window_number],
  150.                                               view[window_number],
  151.                                             (RECTANGLE *) NULL, &wvp);
  152.   dsl[window_number] = TviGetDataSourceList (view[window_number]);
  153.   (VOID) TdlOpenData (dsl[window_number]);
  154.  
  155.   /* Reset the WaitingForExpose flag so updates can continue */
  156.   WaitingForExpose = NO;
  157.  
  158.   return;
  159. }
  160.  
  161. /*----------------------------------------------------------------
  162. |   draw_screen
  163. |       Draw the drawport onto the screen and set status variables.
  164. |
  165. */
  166. void 
  167. draw_screen (window_number)
  168.      int window_number;
  169. {
  170.  
  171.   (VOID) TscErase (DVscreen[window_number]);
  172.   (VOID) TdpDraw (drawport[window_number]);
  173.  
  174.   (VOID) GRset (V_ACTIVE_CURSOR, 0L);
  175.   window_status[window_number] = OPEN;
  176.   if ((window_number == HELP) || (window_number == LEGEND))
  177.     dynamic_status[window_number] = OFF;
  178.   else
  179.     dynamic_status[window_number] = ON;
  180.  
  181.   return;
  182. }
  183.  
  184. /*-------------------------------------------------------------
  185. |
  186. |  SetupDynamics
  187. |       Set up the dynamics for the specified window.
  188. |
  189. */
  190.  
  191. void 
  192. SetupDynamics (window_number)
  193.      int window_number;
  194. {
  195.   switch (window_number)
  196.     {
  197.     case MAIN:
  198.       setup_main_window ();
  199.       break;
  200.     case AMMONIA:
  201.       setup_ammonia_window ();
  202.       break;
  203.     case HP_DRUM:
  204.       setup_hp_drum_window ();
  205.       break;
  206.     case LP_DRUM:
  207.       setup_lp_drum_window ();
  208.       break;
  209.     case HAND:
  210.       setup_hand_window ();
  211.       break;
  212.     case HELP:
  213.       break;
  214.     case LEGEND:
  215.       break;
  216.     }                           /* end switch ( window_number ) */
  217. }
  218.  
  219. /*---------------------------------------------------------------
  220. |
  221. | close_window
  222. |       Close the specified window.
  223. |
  224. */
  225.  
  226. void 
  227. close_window (window_number)
  228.      int window_number;
  229. {
  230.  
  231.   if (window_status[window_number] == OPEN)
  232.     {
  233.       (VOID) TdlCloseData (dsl[window_number]);
  234.       (VOID) VOscSelect (DVscreen[window_number]);
  235.       (VOID) TdpDestroy (drawport[window_number]);
  236.       (VOID) TscClose (DVscreen[window_number]);
  237.       window_status[window_number] = CLOSED;
  238.       dynamic_status[window_number] = OFF;
  239.       DVscreen[window_number] = (LONG)NULL;
  240.     }
  241. }
  242.  
  243. /*-----------------------------------------------------------------
  244. |
  245. |  TermDisplays
  246. |       Performs the termination and clean up needed for the display
  247. |    components.
  248. |
  249. */
  250. void TermDisplays 
  251. V_P_ ((void))
  252. {
  253.   INT i;
  254.  
  255.   /* Destroy, Erase and Close the Windows */
  256.   for (i = (MAXWINS - 1); i >= 0; i--)
  257.     if (window_status[i] == OPEN)
  258.       {
  259.         if (dynamic_status[i] == ON)
  260.           /* Destroy the Dynamic Object Deque */
  261.           VOdqDereference (displaydq[i]);
  262.         /* Close the window */
  263.         close_window (i);
  264.       }
  265. }
  266.